import { StoreSvr } from './../../services/store';
import { PrinterManager } from './../../utils/print/printer/printManager';
import { Component, Output, EventEmitter } from '@angular/core';
@Component({
    selector: 'device-interface',
    template: `
        <div class="flex-column">
            <div (click)="changeName('deviceType')" class="title bg-darkgray">
                <i class="material-icons icon">navigate_before</i>
                <span>选择设备接口类型</span>
            </div>
            <div class="list">
                <section (click)="saveType('usb')">
                    <span class="icon-print icon-usb"></span>
                    <div class="flex-column">
                        <span>USB接口</span>
                        <span class="text-desc">通过USB连接设备</span>
                    </div>
                </section>
                <section (click)="saveType('wifi')">
                    <span class="icon-print icon-wifi"></span>
                    <div class="flex-column">
                        <span>WiFi无线/网口</span>
                        <span class="text-desc">WiFi连接不需要连线，简单方便，有以太网则提供更稳定的连接。网络方式可以不受位置限制，适合厨房打印等远程打印。</span>
                    </div>
                </section>
                <p class="margin-t-m">将设备连接后，打开电源，然后选择相应的类型开始查找。</p>
            </div>
        </div>
        
    `,
    styleUrls: ['./printer.component.scss']
})
export class DeviceInterfaceComponent {
    @Output()
    changePageName: EventEmitter<any> = new EventEmitter<any>();

    constructor(
        private printerManager: PrinterManager,
        private storeSvr: StoreSvr
    ){}

    changeName(name){
        this.changePageName.emit(name);
    }

    saveType(type){
        this.storeSvr.setPrintType(type);
        if(this.storeSvr.getPrintType() == 'wifi'){
            this.changeName('wifiPrint');
        }else{
            this.changeName('searchDevice');
        }
    }

    

}